package com.fg.cloud.common.shiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;

import com.fg.cloud.common.CommonConstants;

/**
 * 用户工具类 - 存储session
 * @author around
 * @date 2017-7-21
 */
public class UserUtils {
	
	private static Session getSession(){
		return SecurityUtils.getSubject().getSession();
	}
	
	public static Object getCurrentUser(){
    	return getSession().getAttribute(CommonConstants.USERINFO);
	}
	
	public static void setCurrentUser(Object currentUser){
		getSession().setAttribute(CommonConstants.USERINFO, currentUser);
	}
	
	public static void clearCachedAuthorizationInfo() {
		getSession().removeAttribute(CommonConstants.USERINFO);
		SecurityUtils.getSubject().logout();
	}
	
}
